<?php
session_start();
if (!isset($_SESSION['authenticated']) || !$_SESSION['authenticated']) {
    header('Location: auth.php'); // 如果未登录，重定向到登录页面
    exit();
}
?>

<?php
$dbFile = '../cms.db';
$pdo = new PDO('sqlite:' . $dbFile);

if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['id'])) {
    $stmt = $pdo->prepare("DELETE FROM posts WHERE id = ?");
    $stmt->execute([$_GET['id']]);
    header("Location: index.php");
}
